import request from "@/utils/request";

const laboratoryManagementAPI = {
  /**
   * 查询检测项目列表
   *
   * @param type 类型
   */
  getLastReportList(type: string) {
    // let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    // console.log(query);
    return request<any, PageResult<Tabulation[]>>({
      url: `/core/inspectionReport/getLastReportList?type=${type}`,
      method: "get",
    });
  },
  /**
   * 查询最近一次记录
   *
   * @param type 类型
   */
  getLastReport(type: string) {
    // let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    // console.log(query);
    return request<any, any>({
      url: `/core/inspectionReport/getLastReport?type=${type}`,
      method: "get",
    });
  },
  /**
   * 化验列表查询
   *
   * @param queryParams 查询参数
   */
  getAnalysisReport(queryParams: qualityPageQuery) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, any>({
      url: `/core/inspectionReport/getAnalysisReport?object=${query}`,
      method: "get",
    });
  },
  /**
   * 化验详情查询
   *
   * @param code  查询参数
   */
  getProdReportByCode(code: any) {
    // let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, any>({
      url: `/core/inspectionReport/getProdReportByCode?code=${code}`,
      method: "get",
    });
  },
  /**
   * 样品种类查询
   *
   * @param category  检测分类 1=蔬果 2=肉类
   * @param sampleName  样品种类名称
   */
  getLastReportBySampleName(data: SampleName) {
    // let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, any>({
      url: `/core/inspectionReport/getLastReportBySampleName`,
      method: "post",
      data: data,
    });
  },

  /**
   * 新增或更新化验单
   *
   * @param data 化验表单
   */
  saveProdReport(data: ProdReportInfo) {
    return request({
      url: `/core/inspectionReport/save`,
      method: "post",
      data: data,
    });
  },
};
export default laboratoryManagementAPI;
/**
 * 查询
 */
export interface qualityPageQuery extends PageQuery {
  /** 产品名 */
  productName?: string;
  status?: string;
  /** 标签码 */
  code?: string;
  // /** 状态 */
  // status?: string;
  // /** 生产时间 */
  // productionTime?: string;
}
export interface SampleName {
  type?: string; //检测分类 1=蔬果 2=肉类
  sampleName?: string; //样品种类名称
}
export interface Tabulation {
  code?: string; //生产批次号
  productName?: string; //产品名称
  productCode?: string; //产品编号
  materialName?: string; //原材料名称
  materialCode?: string; //原材料编号
}
export interface ProdReportInfo {
  id?: string;
  actualQuantity?: number; //实际数量
  basis?: number; //检验依据
  category?: string; //规格
  code?: string; //质检单号
  conclusion?: string; //检验结论
  status?: string; //检验状态
  inspectQty?: number; //抽检数量
  itemCodeList: Inspect[];
  orderType?: number; //订单类型, 0=生产单号, 1=采购单号
  parentCode?: string; //生产单号
  process?: string; //工序
  productCategory?: string; //产品类型
  productCode?: string; //产品编号
  productName?: string; //产品名称
  purchaseQty?: number; //采购数量
  qualityType?: number; //质检单类型, 0=产品质检单, 1=原材料质检单
  remark?: string; //备注
  reportName?: string; //质检人
  reviewName?: string; //复核员
  reportTime?: string; //检验日期
  planDate?: string; //生产日期
  companyName?: string; //生产单位
  standard?: string; //执行标准
  type?: number; //检验类型
  unit: string; //单位
  sampleName: string; //样品种类
}
export interface Inspect {
  id?: string;
  code: string;
  parentCode?: string;
  qcItemCode: string;
  name?: string;
  refValue?: string; //检测标准
  qcValue?: string; //检验结果
  qcResult?: string; //判断结果
  remark?: string; //备注
  refType?: string;
  sampleName: string;
  // parentCode?: string;//质检单号
  // qcItemCode?: string;//质检编号
  // qcRefValue?: string;//检测要求
  // determination?: number;
  // remark?: string;
}
